import request from '@/config/axios'

// 搜索食物
export function searchFood(params) {
  return request({
    url: '/food/search',
    method: 'get',
    params
  })
}

// 获取食物详情
export function getFoodDetail(id) {
  return request({
    url: `/food/${id}`,
    method: 'get'
  })
}

// 获取食物分类
export function getFoodCategories() {
  return request({
    url: '/food/categories',
    method: 'get'
  })
}

// 获取分类下的食物
export function getCategoryFoods(category) {
  return request({
    url: `/food/category/${category}`,
    method: 'get'
  })
}

// 获取常用食物
export function getFrequentFoods() {
  return request({
    url: '/food/frequent',
    method: 'get'
  })
}

// 获取收藏的食物
export function getFavoriteFoods() {
  return request({
    url: '/food/favorites',
    method: 'get'
  })
}

// 收藏食物
export function addFavoriteFood(foodId) {
  return request({
    url: `/food/favorites/${foodId}`,
    method: 'post'
  })
}

// 取消收藏食物
export function removeFavoriteFood(foodId) {
  return request({
    url: `/food/favorites/${foodId}`,
    method: 'delete'
  })
}

// 获取搜索历史
export function getSearchHistory() {
  return request({
    url: '/food/search-history',
    method: 'get'
  })
}

// 清除搜索历史
export function clearSearchHistory() {
  return request({
    url: '/food/search-history',
    method: 'delete'
  })
} 